package com.ms.erpBase;

import java.util.Date;

import javax.servlet.http.HttpSession;

import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Page;
import com.ms.common.model.FeeIncome;
import com.ms.common.util.MsUtility;

public class FeeIncomeController extends Controller {

	public void createOrUpdate(){
	
		FeeIncome be=getBean(FeeIncome.class);
		if(be.getId()==null){
			be.setFeeDate(new Date());
			be.setIsAgree("1");
			HttpSession session=getSession();
			be.setUserId((Integer)session.getAttribute("userId"));
			be.setUserName((String)session.getAttribute("userName"));
			be.save();
		}else{
			be.update();
		}
		renderJsp("/jsp/feeIncome/list.jsp");
	}
	
	
	public void list(){
		Page<FeeIncome> page = FeeIncome.dao.findPageConditions(getModel(FeeIncome.class),getParaToInt("page"),getParaToInt("rows") );
		renderJson(MsUtility.TransToEasyUiPage(page));
		
	}
	
	public void edit(){
		String id=getPara("id");
		FeeIncome be=FeeIncome.dao.findById(id);
		setAttr("FeeIncome", be);
		renderJsp("/jsp/feeIncome/form.jsp");
	}
	
	public void beginCreate(){
		renderJsp("/jsp/feeIncome/form.jsp");
	}
	
	public void delete(){
		String ids=getPara("items");
		String[] idarr=ids.split(",");
		for (String id : idarr) {
			FeeIncome.dao.deleteById(id);
		}
		
		
	}

}
